<?php
	include "../controller/ConectBanco.php";
    include "../controller/Sessao.php";
	
	if($_SESSION["login"] != "admin"){
		header("location:../view/Principal.php");
	}
	$idPonto = $_GET["idPonto"];
	$queryPonto = mysql_query("SELECT * FROM ponto	NATURAL LEFT JOIN device NATURAL JOIN usuario WHERE idPonto = $idPonto")or die(mysql_error());
	$arrayPonto = mysql_fetch_array($queryPonto);
	
?>	

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="UTF-8" />
        <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  -->
        <title>Edicao Ponto</title>
        <link rel="stylesheet" type="text/css" href="../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../css/demo.css" />
    </head>
    <body>
        <div class="container">
           <?php
				include "MenuAdmin.php";
				Menu::data();
				Menu::menuAdmin(); 
			?>
            <header>
                <h1>LOCALIZAGORA<span></br>Sistema de rastreamento via satelite </span></h1>
				
            </header>
            <section>				
                <div id="container_demo" >
                  
                    <div id="wrapper">
                        <div id="login" class="animate form">
                            <form  action="../controller/Editar.php?idPonto=<?php echo $arrayPonto["idPonto"]; ?>" method="post" autocomplete="on" > 
                                <h1>Edicao Ponto</h1> 
                               
                                <p> 
                                   <label for="idUsuario" class="idUsuario"  > idUsuario : </label>
                                   <select name="idUsuario" required="required">
										<option></option>
										<?php 
											$query = mysql_query("SELECT idUsuario,nome FROM usuario");
											while($array = mysql_fetch_array($query)){
												if($arrayPonto['idUsuario'] == $array['idUsuario']){
													echo "<option value='".$array['idUsuario']."' selected>".$array['idUsuario']." - ".$array['nome']." - ".$array['imei'] ."</option>";
												}else{
													echo "<option value='".$array['idUsuario']."'>".$array['idUsuario']." - ".$array['nome']." - ".$array['imei'] ."</option>";
												}
											}
										?>
									</select> 
                                </p>
                                 <p> 
									<label for="idDevice" class="idDevice"  > IdDevice -IMEI </label>
                                    <select name="idDevice" required="required">
										<option></option>
										<?php 
											$query = mysql_query("SELECT idDevice,imei FROM device  ");
											while($array = mysql_fetch_array($query)){
												if($arrayPonto['idDevice'] == $array['idDevice']){
													echo "<option value='".$array['idDevice']."' selected>". $array['idDevice']." - ".$array['imei'] ."</option>";
												}else{
													echo "<option value='".$array['idDevice']."'>". $array['idDevice']." - ".$array['imei'] ."</option>";
												}
																								
											}
										?>
									</select> 
                                </p>
                                 <p> 
                                    <label for="tipo" class="tipo"  > Tipo </label>
                                    
                                    <select name="tipo" required="required">
										<option></option>
										<option value="carro"   <?php if($arrayPonto["tipo"] == "carro")echo "selected";?> >Carro</option>
										<option value="moto"    <?php if($arrayPonto["tipo"] == "moto")echo "selected";?> >Moto</option>
										<option value="maquina" <?php if($arrayPonto["tipo"] == "maquina")echo "selected";?> >Maquina</option>
										<option value="pessoa"  <?php if($arrayPonto["tipo"] == "pessoa")echo "selected";?> >Pessoa</option>
										<option value="crianca" <?php if($arrayPonto["tipo"] == "crianca")echo "selected";?> >Crianca</option>
										<option value="animal"  <?php if($arrayPonto["tipo"] == "animal")echo "selected";?> >Animal</option>
										<option value="outro"   <?php if($arrayPonto["tipo"] == "outro")echo "selected";?> >outro</option>
									</select> 
                                </p>
                                <p> 
                                    <label for="nomePonto" class="nomePonto"  > Nome </label>
                                    <input id="nomePonto" name="nomePonto" required="required" type="text" value="<?php echo $arrayPonto["nomePonto"];?>"/>
                                </p>
                                
                                 <p> 
                                    <label for="info" class="info"  > Informacao </label>
                                    <input id="info" name="info" required="required" type="text" value="<?php echo $arrayPonto["info"];?>"/>
                                </p>                
													
                               <br><br>
                                <p class="button"> 
                                    <input type="submit" value="Salvar" /> 
								</p>
                                
                            </form>
                        </div>
			
                    </div>
                </div>  
            </section>
        </div>
    </body>
</html>
